/*  
 * Actipro Software's WPF DataGrid / Editors Integration Add-on
 * http://actipro.codeplex.com/
 * 
 * Copyright (c) 2009-2015 Actipro Software LLC. 
 *  
 * This source code is subject to the terms of the Microsoft Public License (Ms-PL). 
 *  
 * Redistribution and use in source and binary forms, with or without modification, 
 * is permitted provided that redistributions of the source code retain the above 
 * copyright notices and this file header. 
 *  
 * Additional copyright notices should be appended to the list above. 
 * 
 * For details, see <http://www.opensource.org/licenses/ms-pl.html>. 
 *  
 * All other rights reserved. 
 *
 */


using System;
using System.Diagnostics.CodeAnalysis;
using System.Windows;
using ActiproSoftware.Windows.Controls.Editors.Primitives;

namespace ActiproSoftware.Windows.Controls.Editors.Interop.DataGrid.Primitives {

	/// <summary>
	/// Represents a base class for data-bound columns for use in a <c>DataGrid</c> that utilizes <see cref="Int64EditBoxBase{T}"/>-derived controls.
	/// </summary>
	public abstract class DataGridInt64EditBoxColumnBase<T> : DataGridRangeTypeSpecificEditBoxColumnBase<T> {

		#region Dependency Properties

		/// <summary>
		/// Identifies the <see cref="Format"/> dependency property.  This field is read-only.
		/// </summary>
		/// <value>The identifier for the <see cref="Format"/> dependency property.</value>
		[SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes")]
		public static readonly DependencyProperty FormatProperty = Int64EditBoxBase<T>.FormatProperty.AddOwner(typeof(DataGridInt64EditBoxColumnBase<T>),
			new FrameworkPropertyMetadata("G", OnNotifyablePropertyValueChanged));

		/// <summary>
		/// Identifies the <see cref="StepValue"/> dependency property.  This field is read-only.
		/// </summary>
		/// <value>The identifier for the <see cref="StepValue"/> dependency property.</value>
		[SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes")]
		public static readonly DependencyProperty StepValueProperty = Int64EditBoxBase<T>.StepValueProperty.AddOwner(typeof(DataGridInt64EditBoxColumnBase<T>),
			new FrameworkPropertyMetadata(1L, OnNotifyablePropertyValueChanged));

		#endregion // Dependency Properties

		/////////////////////////////////////////////////////////////////////////////////////////////////////
		#region PUBLIC PROCEDURES
		/////////////////////////////////////////////////////////////////////////////////////////////////////

		/// <summary>
		/// Applies standard values to the specified target element.
		/// </summary>
		/// <param name="targetElement">The target element.</param>
		protected override void ApplyStandardValues(FrameworkElement targetElement) {
			if (targetElement is Int64EditBoxBase<T>) {
				this.ApplyValue(FormatProperty, targetElement, Int64EditBoxBase<T>.FormatProperty);
				this.ApplyValue(StepValueProperty, targetElement, Int64EditBoxBase<T>.StepValueProperty);
			}
			base.ApplyStandardValues(targetElement);
		}

		/// <summary>
		/// Gets or sets the integer format string.
		/// This is a dependency property.
		/// </summary>
		/// <value>
		/// The integer format string.
		/// The default value is <c>"G"</c>.
		/// </value>
		public string Format {
			get { return (string)this.GetValue(DataGridInt64EditBoxColumnBase<T>.FormatProperty); }
			set { this.SetValue(DataGridInt64EditBoxColumnBase<T>.FormatProperty, value); }
		}

		/// <summary>
		/// Gets or sets the value used to increment and decrement the associated value.
		/// This is a dependency property.
		/// </summary>
		/// <value>
		/// The value used to increment and decrement the associated value.
		/// The default value is <c>1</c>.
		/// </value>
		public Int64 StepValue {
			get { return (Int64)this.GetValue(DataGridInt64EditBoxColumnBase<T>.StepValueProperty); }
			set { this.SetValue(DataGridInt64EditBoxColumnBase<T>.StepValueProperty, value); }
		}

		#endregion // PUBLIC PROCEDURES
	}
}
